package com.slz3.business.module.goodsManagement.gooAttribute.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.slz3.business.frame.enums.AuditFlag;
import com.slz3.business.frame.util.VE;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;

@Data
public class GooAttributeCondition extends GooAttribute {

    public static final String CREATE_TIME_OF_PATTERN = "yyyy-MM-dd HH:mm";

    private List<UUID> uuidList;

    private List<AuditFlag> serAuditList;

    @JsonFormat(timezone = "GMT+8", pattern = CREATE_TIME_OF_PATTERN)
    private LocalDateTime createTimeOUTSET;

    @JsonFormat(timezone = "GMT+8", pattern = CREATE_TIME_OF_PATTERN)
    private LocalDateTime createTimeFINISH;

    @JsonFormat(timezone = "GMT+8", pattern = CREATE_TIME_OF_PATTERN)
    private LocalDateTime lastModifyTimeOUTSET;

    @JsonFormat(timezone = "GMT+8", pattern = CREATE_TIME_OF_PATTERN)
    private LocalDateTime lastModifyTimeFINISH;

    private List<UUID> type1UUIDs;
    private List<UUID> type2UUIDs;

    public void setType1UUIDs(List<String> type1UUIDs) {
        if (VE.isNotEmpty(type1UUIDs))
            this.type1UUIDs = type1UUIDs.stream().map(UUID::fromString).collect(Collectors.toList());
    }

    public void setType2UUIDs(List<String> type2UUIDs) {
        if (VE.isNotEmpty(type2UUIDs))
            this.type2UUIDs = type2UUIDs.stream().map(UUID::fromString).collect(Collectors.toList());
    }
}
